//
//  Status.swift
//  Weibo10
//
//  Created by Leon on 15/10/18.
//  Copyright © 2015年 Leon. All rights reserved.
//

import UIKit

class Status: NSObject {

    /// 微博创建时间
    var created_at: String?
    /// 转发微博
    var retweeted_status: Status?
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    /// 转发数
    var reposts_count: Int = 0
    /// 评论数
    var comments_count: Int = 0
    /// 表态数
    var attitudes_count: Int = 0
    /// 用户模型
    var user: User?
    /// 缩略图片地址，没有时不返回此字段
    var pic_urls: [[String: String]]?
    
    
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            if let dict = value as? [String: AnyObject] {
                user = User(dict: dict)
                return
            }
        }
        if key == "retweeted_status" {
            if let dict = value as? [String: AnyObject] {
                retweeted_status = Status(dict: dict)
                return
            }
        }
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String {
        
        let keys = ["created_at", "id", "text", "source", "user", "reposts_count", "comments_count", "attitudes_count", "pic_urls", "retweeted_status"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
